<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        $columns = M('columns')->field('columns')->where(['is_nav'=>0])->select();
        $coList = M('columns')->field('id,pid,columns')->where(['type'=>2])->select();
        $collection = M('collection')->field('id,name,litpic')->select();
        //dump($collection);exit;
        $arr = [];
        foreach($collection as $key => $val){
            $arr[$key]['id']=$val['id'];
            $arr[$key]['name']=$val['name'];
            $arr[$key]['pic']=reset(explode(',', $val['litpic']));
        }
        //dump($arr);exit;
        $single = M('single')->field('id,title,img')->select();
        $article1 = M('article')->field('id,cat_id,title,litpic,content')->where(['id'=>7])->select();

        $article2 = M('article')->field('id,cat_id,title,addtime')->where(['cat_id'=>'新闻中心'])->select();

        $article3 = M('article')->field('id,cat_id,title,litpic,content')->where(['id'=>9])->select();

        $article4 = M('article')->field('id,cat_id,title,addtime')->where(['cat_id'=>'知识百科'])->select();

        $article5 = M('article')->field('id,cat_id,title,content')->where(['cat_id'=>'常见问题'])->select();
        $article6 = M('article')->field('id,cat_id,title,litpic')->where(['cat_id'=>'合作伙伴'])->select();
        $article7 = M('article')->field('id,cat_id,title,litpic')->where(['cat_id'=>'企业相册'])->select();
        $article8 = M('article')->field('id,cat_id,title,litpic')->where(['cat_id'=>'交易记录'])->select();
        $config = M('config')->field('title,value,variable,group_id')->select();
        $array = [];
        foreach($config as $k => $v){
            $array[$v['variable']] = $v['value'];
        }
        $dataList = make_tree($coList);
        $list2 = M('columns') -> field('id,pid,columns') ->where(['type' => '2'])-> select();
        $list2 = make_tree($list2);
        $this ->assign('nav',$list2['0']['_child']);
        unset($coList);
        $this -> assign('article1',$article1);
        $this -> assign('article2',$article2);
        $this -> assign('article3',$article3);
        $this -> assign('article4',$article4);
        $this -> assign('article5',$article5);
        $this -> assign('article6',$article6);
        $this -> assign('article7',$article7);
        $this -> assign('article8',$article8);
        $this -> assign('single',$single);
        $this -> assign('collection',$arr);
        $this -> assign('list',$columns);
        $this -> assign('dataList',$dataList);
        $this->assign('configArr',$array);
        $this->display();
    }
}